package com.ant.storage.handler;

import com.ant.storage.common.ResultCode;
import com.ant.storage.common.ResultInfoInterface;

/**
 * @author hzd
 * @version 1.0
 * @date 2022/3/16 14:17
 */
public class AntException extends  RuntimeException{

    private static final long serialVersionUID = 1L;

    /**
     * 错误码
     */
    protected Integer errorCode;
    /**
     * 错误信息
     */
    protected String errorMsg;

    public AntException() {
        super();
    }
    public AntException(String errorMsg) {
        this.errorMsg = errorMsg;
    }
    public AntException(ResultInfoInterface infoInterface) {
        super(infoInterface.getResultCode().toString());
        this.errorCode = infoInterface.getResultCode();
        this.errorMsg = infoInterface.getResultMsg();
    }
    public AntException(ResultInfoInterface errorInfoInterface, Throwable cause) {
        super(errorInfoInterface.getResultCode().toString(), cause);
        this.errorCode = errorInfoInterface.getResultCode();
        this.errorMsg = errorInfoInterface.getResultMsg();
    }
    public AntException(Integer errorCode, String errorMsg) {
        super(errorCode.toString());
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public AntException(Integer errorCode, String errorMsg, Throwable cause) {
        super(errorCode.toString(), cause);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }
    public AntException(ResultCode resultCode){
        this.errorCode = resultCode.getResultCode();
        this.errorMsg = resultCode.getResultMsg();
    }
//    public AntException(ResultCode resultCode){
//        this(resultCode.getResultCode(),resultCode.getResultMsg());
//    }


    public Integer getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(Integer errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    @Override
    public Throwable fillInStackTrace() {
        return this;
    }

}
